<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        // promise对象中有两个隐藏属性
        // state 状态 pending(未完成)   fulfilled / rejected      
        // resolve被执行会把promise中的状态变成 fulfilled，reject就会把状态变成rejected
        //  状态一旦被改变  就无法还原

         // result结果 resolve和reject传的参数 就会作为结果
         let p = new Promise((resolve,reject) =>{
             resolve(true);
         })
         console.log(p);

         let p1 = new Promise((resolve,reject) =>{
            reject(new Error("错误"));
         })
         console.log(p1);

         let p2 = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve(true)
            }, 5000)
        })

        console.log(p2);
        p2.then();


    </script>
</body>
</html>